package youcaihuaoa.weetop.com.ui.main

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.listener.OnItemClickListener
import com.gyf.immersionbar.ImmersionBar
import com.robot.base.base.activity.GLBaseActivity
import com.robot.base.configs.AppConstants
import com.robot.base.util.arouter.ARouterUtil
import youcaihuaoa.weetop.com.BR
import youcaihuaoa.weetop.com.R
import youcaihuaoa.weetop.com.databinding.AppActivityNotifyMessageBinding
import youcaihuaoa.weetop.com.databinding.AppActivityWagesBinding
import youcaihuaoa.weetop.com.ui.adapter.NotifyItemAdapter
import youcaihuaoa.weetop.com.ui.adapter.WagesItemAdapter
import youcaihuaoa.weetop.com.vm.main.NotifyMessageViewModel
import youcaihuaoa.weetop.com.vm.main.WagesViewModel

@Route(path = AppConstants.Router.Main.A_WAGES)
class WagesActivity :
    GLBaseActivity<AppActivityWagesBinding, WagesViewModel>() {

    private lateinit var wagesAdapter: WagesItemAdapter

    override fun initComponents() {
        addSingleTitleBar("我的工资")
        wagesAdapter = WagesItemAdapter().apply {
            setOnItemClickListener { _, _, position ->
                ARouterUtil.goToActivityWithBundle(
                    AppConstants.Router.Main.A_WAGES_PROFILE, Bundle().apply {
                        putString(AppConstants.BundleKey.ID, wagesAdapter.data[position].id)
                    }
                )
            }
        }
        binding.recyclerView.apply {
            layoutManager = LinearLayoutManager(this@WagesActivity)
            adapter = wagesAdapter
        }

        viewModel.getUserWagesList()
    }

    override fun initContentView(savedInstanceState: Bundle?): Int =
        R.layout.app_activity_wages

    override fun initVariableId(): Int = BR.viewModel

    override fun initViewObservable() {
        super.initViewObservable()
        viewModel.uiChangeEvent.dataEvent.observe(this) {
            wagesAdapter.setList(it)
        }
    }
}